<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改设备材料合同')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sbclht-edit" th:object="${gcProjectSbclht}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="gcProjectid" th:field="*{gcProjectid}" type="hidden">
            <input name="zlwj" th:field="*{zlwj}" type="hidden">
            <input name="jhd" id="jhd" th:value="${jhd}" type="hidden">
            
            <input name="hzzszlwj" th:field="*{hzzszlwj}" type="hidden">
            <h4 class="form-header h4">基本信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">合同编号：</label>
                <div class="col-sm-8">
                    <input name="orderNo" th:field="*{orderNo}" readonly="readonly" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" readonly="readonly" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">供应商名称：</label>
                <div class="col-sm-8">
                	<input name="supplyName" th:field="*{supplyName}" readonly="readonly" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">合同总金额：</label>
                <div class="col-sm-8">
                    <input name="zongje" th:field="*{zongje}" required class="form-control" readonly="readonly" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同简要说明：</label>
                <div class="col-sm-8">
                    <textarea name="descs" class="form-control" readonly="readonly">[[*{descs}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">评审合同文件：</label>
                <div class="col-sm-8" style="margin-top: 8px;" id="zlwjlink">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">正式合同文件：</label>
                <div class="col-sm-8" id="htzlwjlink">
                </div>
            </div>
			<h4 class="form-header h4" style="margin-top: 8px;">交货单</h4>
            <div class="form-group">
                <label class="col-sm-3 control-label">资料文件：</label>
                	<div class="col-sm-8" style="margin-top: 8px;" id="jhdzlwjlink">
                </div>
            </div>
            <h4 class="form-header h4">进项发票汇总</h4>
            <div class="form-group">
		        <div class="col-sm-12 ">
				    <table id="bootstrap-table"></table>
				</div>
				<div class="col-sm-12 " style="margin-top: 12px;text-align: left;font-size: 17px;color: red;">
				进项发票汇总金额：<span th:text="${fpjehz}"></span>
				</div>
			</div>
			<h4 class="form-header h4">付款汇总</h4>
			<div class="form-group">
		        <div class="col-sm-12 ">
				    <table id="bootstrap-table-fk"></table>
				</div>
				<div class="col-sm-12 " style="margin-top: 12px;text-align: left;font-size: 17px;color: red;">
				付款汇总金额：<span th:text="${fkjehz}"></span>
				</div>
			</div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/sbclht";
        $("#form-sbclht-edit").validate({
            focusCleanup: true
        });
        
        $(function() {
        	
        	// 初始化数据, 可以由后台传过来
	    	var data = [[${fkfplis}]];
		    var options = {
		    	data: data,
                pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
		        columns: [
		        {
		        	field: 'index',
		        	align: 'center',
		        	title: "序号",
		        	width:50,
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	var columnId = $.common.sprintf("<input type='hidden' name='item[%s].xuh' value='%s'>", index, row.id);
                    	return columnIndex + $.table.serialNumber(index) + columnId;
                    }
                },
                {
		            field: 'fpriqvo',
		            align: 'center',
		            title: '开票日期',
		            width:100,
	                formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
	                }
		        },
		        {
		            field: 'fpNo',
		            align: 'center',
		            title: '发票号码',
		            width:100,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            field: 'fpType',
		            align: 'center',
		            title: '发票类型',
		            width:100,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            field: 'fpsl',
		            align: 'center',
		            title: '发票税率',
		            width:100,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>%';
                    }
		        },
		        {
		            align: 'center',
		            title: '发票数量',
		            width:100,
			        formatter: function(value, row, index) {
		        		return '<span>1</span>';
	                }
		        },
		        {
		            field: 'fpjine',
		            align: 'center',
		            title: '发票金额',
		            width:100,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            field: 'ckdw',
		            align: 'center',
		            title: '供应商名称',
		            width:220,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            field: 'fap',
		            align: 'center',
		            title: '发票扫描件',
		            formatter: function(value, row, index) {
		        		return '<a href="'+value+'" target="_blank">' + value + '</a>';
                    }
		        }]
		    };
		    $.table.init(options);
		    
		    var datafk = [[${fklis}]];
		    var optionsfk = {
		    	data: datafk,
                pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
		        columns: [
		        {
		        	field: 'index',
		        	align: 'center',
		        	title: "序号",
		        	width:50,
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	var columnId = $.common.sprintf("<input type='hidden' name='item[%s].xuh' value='%s'>", index, row.id);
                    	return columnIndex + $.table.serialNumber(index) + columnId;
                    }
                },
                {
		            field: 'riq',
		            align: 'center',
		            title: '付款日期',
		            width:300,
	                formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
	                }
		        },
		        {
		            field: 'ljzf',
		            align: 'center',
		            title: '支付金额',
		            width:300,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            field: 'ckdw',
		            align: 'center',
		            title: '供应商名称',
		            width:220,
		            formatter: function(value, row, index) {
		        		return '<span>' + value + '</span>';
                    }
		        },
		        {
		            align: 'center',
		            title: '其它',
	                formatter: function(value, row, index) {
		        		return '<span>&nbsp;</span>';
	                }
		        },]
		    };
		    $("#bootstrap-table-fk").bootstrapTable(optionsfk);
        	
			var zilwj = $("#zlwj").val();
        	var n=zilwj.split(",");
        	for(var i=0;i<n.length;i++){
        		if(n[i]!=""){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zlwjlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a>&nbsp;&nbsp;&nbsp;&nbsp;");
        		$("#zlwjlink").append("<a href='"+n[i]+"' target='_blank' >下载</a><br>");
        		}
        	}
        	
        	var hzzszlwj = $("#hzzszlwj").val();
        	var n=hzzszlwj.split(",");
        	for(var i=0;i<n.length;i++){
        		if(n[i]!=""){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#htzlwjlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a>&nbsp;&nbsp;&nbsp;&nbsp;");
        		$("#htzlwjlink").append("<a href='"+n[i]+"' target='_blank' >下载</a><br>");
        		}
        	}
        	
			var jhd = $("#jhd").val();
        	var kk=jhd.split(",");
        	for(var x=0;x<kk.length;x++){
        		if(kk[x]!=""){
//         		var kkurl = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(kk[x]));
        		var kkurl = kk[i];
        		$("#jhdzlwjlink").append("<a href='"+kkurl+"' target='_blank' >"+kk[x]+"</a>&nbsp;&nbsp;&nbsp;&nbsp;");
        		$("#jhdzlwjlink").append("<a href='"+kk[x]+"' target='_blank' >下载</a><br>");
    			}
        	}
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
            	var form = document.getElementById("form-sbclht-edit");
                var file = new FormData(form);
                $.ajax({
                    url: "/gcgl/sbclht/edit",
                    type: "POST",
                    processData:false,
                    contentType:false,
                    //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
                    data:file,
                    success: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    },
                    error: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    }
                })
            	
                //$.operate.save(prefix + "/edit", $('#form-sbclht-edit').serialize());
            }
        }

    </script>
</body>
</html>